home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Freeware 2002 November
/
SGI Freeware 2002 November - Disc 2.iso
/
dist
/
fw_groff.idb
/
usr
/
freeware
/
info
/
groff-2.z
/
groff-2
Wrap
Text File
|
2002-04-08
|
51KB
|
1,533 lines
This is groff, produced by makeinfo version 4.0 from groff.texinfo.
INFO-DIR-SECTION Miscellaneous
START-INFO-DIR-ENTRY
* Groff: (groff). The GNU troff document formatting system.
END-INFO-DIR-ENTRY
This Info file documents GNU troff version 1.16.
Published by the Free Software Foundation 59 Temple Place, Suite 330
Boston, MA 02111-1307 USA
Copyright (C) 1994-2000 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be stated in a
translation approved by the Foundation.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the section entitled "GNU General Public License" is included
exactly as in the original, and provided that the entire resulting
derived work is distributed under the terms of a permission notice
identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the section entitled "GNU General Public License"
may be included in a translation approved by the Free Software
Foundation instead of in the original English.
File: groff, Node: Basics, Next: Common Features, Prev: Tutorial for Macro Users, Up: Tutorial for Macro Users
Basics
======
This section covers some of the basic concepts necessary to
understand how to use a macro package.(1) (*note Basics-Footnote-1::)
References are made throughout to more detailed information, if desired.
`gtroff' reads an input file prepared by the user and outputs a
formatted document suitable for publication or framing. The input
consists of text, or words to be printed, and embedded commands
("requests" and "escapes"), which tell `gtroff' how to format the
output. For more detail on this, see *Note Embedded Commands::.
The word "argument" is used in this chapter to mean a word or number
which appears on the same line as a request, and which modifies the
meaning of that request. For example, the request
.sp
spaces one line, but
.sp 4
spaces four lines. The number 4 is an argument to the `sp' request
which says to space four lines instead of one. Arguments are separated
from the request and from each other by spaces (_no_ tabs). More
details on this can be found in *Note Request Arguments::.
The primary function of `gtroff' is to collect words from input
lines, fill output lines with those words, justify the right-hand margin
by inserting extra spaces in the line, and output the result. For
example, the input:
Now is the time
for all good men
to come to the aid
of their party.
Four score and seven
years ago,...
is read, packed onto output lines, and justified to produce:
Now is the time for all good men to come to the aid of their party.
Four score and seven years ago,...
Sometimes a new output line should be started even though the current
line is not yet full; for example, at the end of a paragraph. To do
this it is possible to cause a "break", which starts a new output line.
Some requests cause a break automatically, as normally do blank input
lines and input lines beginning with a space.
Not all input lines are text to be formatted. Some input lines are
requests which describe how to format the text. Requests always have a
period (`.') or an apostrophe (`'') as the first character of the input
line.
The text formatter also does more complex things, such as
automatically numbering pages, skipping over page boundaries, putting
footnotes in the correct place, and so forth.
Here are a few hints for preparing text for input to `gtroff'.
* First, keep the input lines short. Short input lines are easier to
edit, and `gtroff' packs words onto longer lines anyhow.
* In keeping with this, it is helpful to begin a new line after every
comma or phrase, since common corrections are to add or delete
sentences or phrases.
* End each sentence with two spaces - or better, start each sentence
on a new line. `gtroff' recognizes characters that usually end a
sentence, and inserts sentence space accordingly.
* Do not hyphenate words at the end of lines - `gtroff' is smart
enough to hyphenate words as needed, but is not smart enough to
take hyphens out and join a word back together. Also, words such
as "mother-in-law" should not be broken over a line, since then a
space can occur where not wanted, such as "mother- in-law".
`gtroff' double spaces output text automatically if you use the
request `.ls 2'. Reactivate single spaced mode by typing `.ls 1'.
A number of requests allow to change the way the output looks,
sometimes called the "layout" of the output page. Most of these
requests adjust the placing of "white space" (blank lines or spaces).
The `.bp' request starts a new page, causing a line break.
The request `.sp N' leaves N lines of blank space. N can be omitted
(meaning skip a single line) or can be of the form Ni (for N inches) or
Nc (for N centimeters). For example, the input:
.sp 1.5i
My thoughts on the subject
.sp
leaves one and a half inches of space, followed by the line "My
thoughts on the subject", followed by a single blank line (more
measurement units are available, see *Note Measurements::).
Text lines can be centered by using the `ce' request. The line
after `ce' is centered (horizontally) on the page. To center more than
one line, use `.ce N' (where N is the number of lines to center),
followed by the N lines. To center many lines without counting them,
type:
.ce 1000
lines to center
.ce 0
The `.ce 0' request tells `groff' to center zero more lines, in other
words, stop centering.
All of these requests cause a break; that is, they always start a new
line. To start a new line without performing any other action, use
`br'.
File: groff, Node: Basics-Footnotes, Up: Basics
(1) This section is derived from `Writing Papers with nroff using
-me' by Eric P. Allman.
File: groff, Node: Common Features, Prev: Basics, Up: Tutorial for Macro Users
Common Features
===============
`gtroff' provides very low-level operations for formatting a
document. There are many common routine operations which are done in
all documents. These common operations are written into "macros" and
collected into a "macro package".
All macro packages provide certain common capabilities which fall
into the following categories.
* Menu:
* Paragraphs::
* Sections and Chapters::
* Headers and Footers::
* Page Layout Adjustment::
* Displays::
* Footnotes and Annotations::
* Table of Contents::
* Indices::
* Paper Formats::
* Multiple Columns::
* Font and Size Changes::
* Predefined Strings::
* Preprocessor Support::
* Configuration and Customization::
File: groff, Node: Paragraphs, Next: Sections and Chapters, Prev: Common Features, Up: Common Features
Paragraphs
----------
One of the most common and most used capability is starting a
paragraph. There are a number of different types of paragraphs, any of
which can be initiated with macros supplied by the macro package.
Normally, paragraphs start with a blank line and the first line
indented, like the text in this manual. There are also block style
paragraphs, which omit the indentation:
Some men look at constitutions with sanctimonious
reverence, and deem them like the ark of the covenant, too
sacred to be touched.
And there are also indented paragraphs which begin with a tag or label
at the margin and the remaining text indented.
one This is the first paragraph. Notice how the first
line of the resulting paragraph lines up with the
other lines in the paragraph.
longlabel
This paragraph had a long label. The first
character of text on the first line does not line up
with the text on second and subsequent lines,
although they line up with each other.
A variation of this is a bulleted list.
File: groff, Node: Sections and Chapters, Next: Headers and Footers, Prev: Paragraphs, Up: Common Features
Sections and Chapters
---------------------
Most macro packages supply some form of section headers. The
simplest kind is simply the heading on a line by itself in bold type.
Others supply automatically numbered section heading or different
heading styles at different levels. Some, more sophisticated, macro
packages supply macros for starting chapters and appendices.
File: groff, Node: Headers and Footers, Next: Page Layout Adjustment, Prev: Sections and Chapters, Up: Common Features
Headers and Footers
-------------------
Every macro package gives some way to manipulate the headers and
footers (or "titles") on each page. Some packages allow for different
ones on the even and odd pages (for material printed in a book form).
The titles are called three-part titles, that is, there is a
left-justified part, a centered part, and a right-justified part. An
automatically generated page number may be put in any of these fields
with the `%' character (see *Note Page Layout::, for more details).
File: groff, Node: Page Layout Adjustment, Next: Displays, Prev: Headers and Footers, Up: Common Features
Page Layout
-----------
Most macro packages let the user specify top and bottom margins and
other details about the appearance of the printed pages.
File: groff, Node: Displays, Next: Footnotes and Annotations, Prev: Page Layout Adjustment, Up: Common Features
Displays
--------
Displays are sections of text to be set off from the body of the
paper. Major quotes, tables, and figures are types of displays, as are
all the examples used in this document.
"Major quotes" are quotes which are several lines long, and hence
are set in from the rest of the text without quote marks around them.
A "list" is an indented, single spaced, unfilled display. Lists
should be used when the material to be printed should not be filled and
justified like normal text, such as columns of figures or the examples
used in this paper.
A "keep" is a display of lines which are kept on a single page if
possible. An example for a keep might be a diagram. Keeps differ from
lists in that lists may be broken over a page boundary whereas keeps are
not.
Floating keeps move relative to the text. Hence, they are good for
things which are referred to by name, such as "See figure 3". A
floating keep appears at the bottom of the current page if it fits;
otherwise, it appears at the top of the next page. Meanwhile, the
surrounding text `flows' around the keep, thus leaving no blank areas.
File: groff, Node: Footnotes and Annotations, Next: Table of Contents, Prev: Displays, Up: Common Features
Footnotes and Annotations
-------------------------
There are a number of requests to save text for later printing.
"Footnotes" are printed at the bottom of the current page.
"Delayed text" is very similar to a footnote except that it is
printed when called for explicitly. This allows a list of references to
appear (for example) at the end of each chapter, as is the convention in
some disciplines.
Most macro packages which supply this functionality also supply a
means of automatically numbering either type of annotation.
File: groff, Node: Table of Contents, Next: Indices, Prev: Footnotes and Annotations, Up: Common Features
Table of Contents
-----------------
"Tables of contents" are a type of delayed text having a tag
(usually the page number) attached to each entry after a row of dots.
The table accumulates throughout the paper until printed, usually after
the paper has ended. Many macro packages provide the ability to have
several tables of contents (e.g. a standard table of contents, a list
of tables, etc).
File: groff, Node: Indices, Next: Paper Formats, Prev: Table of Contents, Up: Common Features
Indices
-------
While some macro packages use the term "index", none actually
provide that functionality. The facilities they call indices are
actually more appropriate for tables of contents.
File: groff, Node: Paper Formats, Next: Multiple Columns, Prev: Indices, Up: Common Features
Paper Formats
-------------
Some macro packages provide stock formats for various kinds of
documents. Many of them provide a common format for the title and
opening pages of a technical paper. The `mm' macros in particular
provide formats for letters and memoranda.
File: groff, Node: Multiple Columns, Next: Font and Size Changes, Prev: Paper Formats, Up: Common Features
Multiple Columns
----------------
Some macro packages (but not `man') provide the ability to have two
or more columns on a page.
File: groff, Node: Font and Size Changes, Next: Predefined Strings, Prev: Multiple Columns, Up: Common Features
Font and Size Changes
---------------------
The built-in font and size functions are not always intuitive, so all
macro packages provide macros to make these operations simpler.
File: groff, Node: Predefined Strings, Next: Preprocessor Support, Prev: Font and Size Changes, Up: Common Features
Predefined Strings
------------------
Most macro packages provide various predefined strings for a variety
of uses; examples are sub- and superscripts, printable dates, quotes and
various special characters.
File: groff, Node: Preprocessor Support, Next: Configuration and Customization, Prev: Predefined Strings, Up: Common Features
Preprocessor Support
--------------------
All macro packages provide support for the various preprocessors and
may extend their functionality.
For example, all macro packages mark tables (which are processed with
`gtbl') by placing them between `.TS' and `.TE' macros. The `ms' macro
package has an option, `.TSH', that prints a caption at the top of a
new page (when the table is too long to fit on a single page).
File: groff, Node: Configuration and Customization, Prev: Preprocessor Support, Up: Common Features
Configuration and Customization
-------------------------------
Some macro packages provide means of customizing many of the details
of how the package behaves. This ranges from setting the default type
size to changing the appearance of section headers.
File: groff, Node: Macro Packages, Next: gtroff Reference, Prev: Tutorial for Macro Users, Up: Top
Macro Packages
**************
This chapter documents the main macro packages that come with
`groff'.
* Menu:
* man::
* mdoc::
* ms::
* me::
* mm::
File: groff, Node: man, Next: mdoc, Prev: Macro Packages, Up: Macro Packages
`man'
=====
This is the most popular and probably the most important macro
package of `groff'. It is easy to use, and a vast majority of manual
pages are based on it.
* Menu:
* Man options::
* Man usage::
* Man font macros::
* Miscellaneous man macros::
* Predefined man strings::
* Preprocessors in man pages::
File: groff, Node: Man options, Next: Man usage, Prev: man, Up: man
Options
-------
The command line format for using the `man' macros with `groff' is:
groff -m man [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [ -rPNNN ]
[ -rSXX ] [ -rXNNN ] [ FILES... ]
It is possible to use `-man' instead of `-m man'.
`-rcR=1'
This option (the default if a tty output device is used) creates a
single, very long page instead of multiple pages. Use `-rcR=0' to
disable it.
`-rC1'
If more than one manual page is given on the command line, number
the pages continuously, rather than starting each at 1.
`-rD1'
Double-sided printing. Footers for even and odd pages are
formatted differently.
`-rPNNN'
Page numbering starts with NNN rather than with 1.
`-rSXX'
Use XX (which can be 10, 11, or 12pt) as the base document font
size instead of the default value of 10pt.
`-rXNNN'
After page NNN, number pages as NNNa, NNNb, NNNc, etc. For
example, the option `-rX2' produces the following page numbers: 1,
2, 2a, 2b, 2c, etc.
File: groff, Node: Man usage, Next: Man font macros, Prev: Man options, Up: man
Usage
-----
This section describes the available macros for manual pages. For
further customization, put additional macros and requests into the file
`man.local' which is loaded immediately after the `man' package.
- Macro: .TH title section [extra1] [extra2] [extra3]
Set the title of the man page to TITLE and the section to SECTION,
which must have a value between 1 and 8. The value of SECTION may
also have a string appended, e.g. `.pm', to indicate a specific
subsection of the man pages.
Both TITLE and SECTION are positioned at the left and right in the
header line (with SECTION in parentheses immediately appended to
TITLE. EXTRA1 is positioned in the middle of the footer line.
EXTRA2 is positioned at the left in the footer line (or at the
left on even pages and at the right on odd pages if double-sided
printing is active). EXTRA3 is centered in the header line.
For HTML output, headers and footers are completely suppressed.
Additionally, this macro starts a new page; the new line number
is 1 again (except if the `-rC1' option is given on the command
line) - this feature is intended only for formatting multiple man
pages; a single man page should contain exactly one `TH' macro at
the beginning of the file.
- Macro: .SH [heading]
Set up an unnumbered section heading sticking out to the left.
Prints out all the text following `SH' up to the end of the line
(or the text in the next line if there is no argument to `SH') in
bold face, one size larger than the base document size.
Additionally, the left margin for the following text is reset to
its default value.
- Macro: .SS [heading]
Set up an unnumbered (sub)section heading. Prints out all the text
following `SS' up to the end of the line (or the text in the next
line if there is no argument to `SS') in bold face, at the same
size as the base document size. Additionally, the left margin for
the following text is reset to its default value.
- Macro: .TP [nnn]
Set up an indented paragraph with label. The indentation is set to
NNN if that argument is supplied (the default unit is `n' if
omitted), otherwise it is set to the default indentation value.
The first line of text following this macro is interpreted as a
string to be printed flush-left, as it is appropriate for a label.
It is not interpreted as part of a paragraph, so there is no
attempt to fill the first line with text from the following input
lines. Nevertheless, if the label is not as wide as the
indentation, then the paragraph starts at the same line (but
indented), continuing on the following lines. If the label is
wider than the indentation, then the descriptive part of the
paragraph begins on the line following the label, entirely
indented. Note that neither font shape nor font size of the label
is set to a default value; on the other hand, the rest of the text
has default font settings.
- Macro: .LP
- Macro: .PP
- Macro: .P
These macros are mutual aliases. Any of them causes a line break
at the current position, followed by a vertical space downwards by
the amount specified by the `PD' macro. The font size and shape
are reset to the default value (10pt roman). Finally, the current
left margin is restored.
- Macro: .IP [designator] [nnn]
Set up an indented paragraph, using DESIGNATOR as a tag to mark
its beginning. The indentation is set to NNN if that argument is
supplied (default unit is `n'), otherwise the default indentation
value is used. Font size and face of the paragraph (but not the
designator) are reset to their default values. To start an
indented paragraph with a particular indentation but without a
designator, use `""' (two double quotes) as the first argument of
`IP'.
For example, to start a paragraph with bullets as the designator
and 4en indentation, write
.IP \(bu 4
- Macro: .HP [nnn]
Set up a paragraph with hanging left indentation. The indentation
is set to NNN if that argument is supplied (default unit is `n'),
otherwise the default indentation value is used. Font size and
face are reset to their default values.
- Macro: .RS [nnn]
Move the left margin to the right by the value NNN if specified
(default unit is `n'); otherwise the default indentation value is
used. Calls to the `RS' macro can be nested.
- Macro: .RE [nnn]
Move the left margin back to level NNN; if no argument is given,
it moves one level back. The first level (i.e., no call to `RS'
yet) has number 1, and each call to `RS' increases the level by 1.
To summarize, the following macros cause a line break with the
insertion of vertical space (which amount can be changed with the `PD'
macro): `SH', `SS', `TP', `LP' (`PP', `P'), `IP', and `HP'.
The macros `RS' and `RE' also cause a break but do not insert
vertical space.
File: groff, Node: Man font macros, Next: Miscellaneous man macros, Prev: Man usage, Up: man
Macros to set fonts
-------------------
The standard font is roman; the default text size is 10 point.
- Macro: .SM [text]
Set the text on the same line or the text on the next line in a
font that is one point size smaller than the default font.
- Macro: .SB [text]
Set the text on the same line or the text on the next line in
boldface font, one point size smaller than the default font.
- Macro: .BI text
Set its arguments alternately in bold face and italic. Thus,
.BI this "word and" that
would set "this" and "that" in bold face, and "word and" in
italics.
- Macro: .IB text
Set its arguments alternately in italic and bold face.
- Macro: .RI text
Set its arguments alternately in roman and italic.
- Macro: .IR text
Set its arguments alternately in italic and roman.
- Macro: .BR text
Set its arguments alternately in bold face and roman.
- Macro: .RB text
Set its arguments alternately in roman and bold face.
- Macro: .R [text]
Set TEXT in roman font. If no text is present on the line where
the macro is called, then the text of the next line appears in
roman. This is the default font to which text is returned at the
end of processing of the other macros.
- Macro: .B [text]
Set TEXT in bold face. If no text is present on the line where
the macro is called, then the text of the next line appears in bold
face.
- Macro: .I [text]
Set TEXT in italic. If no text is present on the line where the
macro is called, then the text of the next line appears in italic.
File: groff, Node: Miscellaneous man macros, Next: Predefined man strings, Prev: Man font macros, Up: man
Miscellaneous macros
--------------------
The default indentation is 7.2n for all output devices except for
`grohtml' which ignores indentation.
- Macro: .DT
Set tabs every 0.5 inches. Since this macro is always called
during a `TH' request, it makes sense to call it only if the tab
positions have been changed.
- Macro: .PD [nnn]
Adjust the empty space before a new paragraph (or section). The
optional argument gives the amount of space (default unit is `v');
without parameter, the value is reset to its default value (1 line
for tty devices, 0.4v otherwise).
This affects the macros `SH', `SS', `TP', `LP' (as well as `PP' and
`P'), `IP', and `HP'.
File: groff, Node: Predefined man strings, Next: Preprocessors in man pages, Prev: Miscellaneous man macros, Up: man
Predefined strings
------------------
The following strings are defined:
- String: *S
Switch back to the default font size.
- String: *R
The `registered' sign.
- String: Tm
The `trademark' sign.
- String: lq
- String: rq
Left and right quote. This is equal to `\(lq' and `\(rq',
respectively.
File: groff, Node: Preprocessors in man pages, Prev: Predefined man strings, Up: man
Preprocessors in `man' pages
----------------------------
If a preprocessor like `gtbl' or `geqn' is needed, it has become
common usage to make the first line of the man page look like this:
.\" WORD
Note the single space character after the double quote. WORD consists
of letters for the needed preprocessors: `e' for `geqn', `r' for
`grefer', `t' for `gtbl'. Modern implementations of the `man' program
read this first line and automatically call the right preprocessor(s).
File: groff, Node: mdoc, Next: ms, Prev: man, Up: Macro Packages
`mdoc'
======
File: groff, Node: ms, Next: me, Prev: mdoc, Up: Macro Packages
`ms'
====
File: groff, Node: me, Next: mm, Prev: ms, Up: Macro Packages
`me'
====
File: groff, Node: mm, Prev: me, Up: Macro Packages
`mm'
====
File: groff, Node: gtroff Reference, Next: Preprocessors, Prev: Macro Packages, Up: Top
`gtroff' Reference
******************
This chapter covers *all* of the facilities of `gtroff'. Users of
macro packages may skip it if not interested in details.
* Menu:
* Text::
* Input Conventions::
* Measurements::
* Expressions::
* Identifiers::
* Embedded Commands::
* Registers::
* Manipulating Filling and Adjusting::
* Manipulating Hyphenation::
* Manipulating Spacing::
* Tabs and Fields::
* Character Translations::
* Troff and Nroff Mode::
* Line Layout::
* Page Layout::
* Page Control::
* Fonts::
* Sizes::
* Strings::
* Conditionals and Loops::
* Writing Macros::
* Page Motions::
* Drawing Requests::
* Traps::
* Diversions::
* Environments::
* Suppressing output::
* I/O::
* Postprocessor Access::
* Miscellaneous::
* Gtroff Internals::
* Debugging::
* Implementation Differences::
* Summary::
File: groff, Node: Text, Next: Input Conventions, Prev: gtroff Reference, Up: gtroff Reference
Text
====
`gtroff' input files contain text with control commands interspersed
throughout. But, even without control codes, `gtroff' still does
several things with the input text:
* filling and adjusting
* adding additional space after sentences
* hyphenating
* inserting implicit line breaks
* Menu:
* Filling and Adjusting::
* Hyphenation::
* Sentences::
* Tab Stops::
* Implicit Line Breaks::
File: groff, Node: Filling and Adjusting, Next: Hyphenation, Prev: Text, Up: Text
Filling and Adjusting
---------------------
When `gtroff' reads text, it collects words from the input and fits
as many of them together on one output line as it can. This is known as
"filling".
Once `gtroff' has a "filled" line, it tries to "adjust" it. This
means it widens the spacing between words until the text reaches the
right margin (in the default adjustment mode). Extra spaces between
words are preserved, but spaces at the end of lines are ignored.
Spaces at the front of a line cause a "break" (breaks are explained in
*Note Implicit Line Breaks::)
*Note Manipulating Filling and Adjusting::.
File: groff, Node: Hyphenation, Next: Sentences, Prev: Filling and Adjusting, Up: Text
Hyphenation
-----------
Since the odds are not great for finding a set of words, for every
output line, which fit nicely on a line without inserting excessive
amounts of space between words, `gtroff' hyphenates words so that it
can justify lines without inserting too much space between words. It
uses an internal hyphenation algorithm (a simplified version of the
algorithm used within TeX) to indicate which words can be hyphenated
and how to do so. When a word is hyphenated, the first part of the
word is added to the current filled line being output (with an attached
hyphen), and the other portion is added to the next line to be filled.
*Note Manipulating Hyphenation::.
File: groff, Node: Sentences, Next: Tab Stops, Prev: Hyphenation, Up: Text
Sentences
---------
Although it is often debated, some typesetting rules say there
should be different amounts of space after various punctuation marks.
For example, the `Chicago typsetting manual' says that a period at the
end of a sentence should have twice as much space following it as would
a comma or a period as part of an abbreviation.
`gtroff' does this by flagging certain characters (normally `!',
`?', and `.') as "end of sentence" characters. When `gtroff'
encounters one of these characters at the end of a line, it appends a
normal space followed by a "sentence space" in the formatted output.
(This justifies one of the conventions mentioned in *Note Input
Conventions::.)
In addition, the following characters or glyphs are treated
transparently while handling end of sentence characters: `"', `'', `)',
`]', `*', `dg', and `rq'.
See the `cflags' request in *Note Using Symbols::, for more details.
To prevent the insertion of extra space after an end of sentence
character (at the end of a line), append `\&'.
File: groff, Node: Tab Stops, Next: Implicit Line Breaks, Prev: Sentences, Up: Text
Tab Stops
---------
`gtroff' translates "tabulator characters", also called "tabs"
(normally code point ASCII `0x09' or EBCDIC `0x05'), in the input into
movements to the next tabulator stop. These tab stops are initially
located every half inch across the page. Using this, simple tables can
be made easily. However, it can often be deceptive as the appearance
(and width) of the text on a terminal and the results from `gtroff' can
vary greatly.
Also, a possible sticking point is that lines beginning with tab
characters are still filled, again producing unexpected results. For
example, the following input
1 2 3
4 5
produces
1 2 3 4 5
*Note Tabs and Fields::.
File: groff, Node: Implicit Line Breaks, Prev: Tab Stops, Up: Text
Implicit Line Breaks
--------------------
An important concept in `gtroff' is the "break". When a break
occurs, `gtroff' outputs the partially filled line (unjustified), and
resumes collecting and filling text on the next output line.
There are several ways to cause a break in `gtroff'. A blank line
not only causes a break, but it also outputs a one line vertical space
(effectively a blank line). Note that this behaviour can be modified
with the blank line macro request `blm'.
A line that begins with a space causes a break and the space is
output at the beginning of the next line. Note that this space isn't
adjusted, even in fill mode.
The end of file also causes a break - otherwise the last line of the
document may vanish!
Certain requests also cause breaks, implicitly or explicitly. This
is discussed in *Note Manipulating Filling and Adjusting::.
File: groff, Node: Input Conventions, Next: Measurements, Prev: Text, Up: gtroff Reference
Input Conventions
=================
Since `gtroff' does filling automatically, it is traditional in
`groff' not to try and type things in as nicely formatted paragraphs.
These are some conventions commonly used when typing `gtroff' text:
* Break lines after punctuation, particularly at the end of a
sentence and in other logical places. Keep separate phrases on
lines by themselves, as entire phrases are often added or deleted
when editing.
* Try to keep lines less than 40-60 characters, to allow space for
inserting more text.
* Do not try to do any formatting in a WYSIWYG manner (i.e., don't
try using spaces to get proper indentation).
File: groff, Node: Measurements, Next: Expressions, Prev: Input Conventions, Up: gtroff Reference
Measurements
============
`gtroff' (like many other programs) requires numeric parameters to
specify various measurements. Most numeric parameters(1) (*note
Measurements-Footnote-1::) may have a "measurement unit" attached.
These units are specified as a single character which immediately
follows the number or expression. Each of these units are understood,
by `gtroff', to be a multiple of its "basic unit". So, whenever a
different measurement unit is specified `gtroff' converts this into its
"basic units". This basic unit, represented by a `u', is a device
dependent measurement which is quite small, ranging from 1/75th to
1/72000th of an inch. The values may be given as fractional numbers;
however, fractional basic units are always rounded to integers.
Some of the measurement units are completely independent of any of
the current settings (e.g. type size) of `gtroff'.
`i'
Inches. An antiquated measurement unit still in use in certain
backwards countries with incredibly low-cost computer equipment.
One inch is equal to 2.54cm.
`c'
Centimeters. One centimeter is equal to 0.3937in.
`p'
Points. This is a typesetter's measurement used for measure type
size. It is 72 points to an inch.
`P'
Pica. Another typesetting measurement. 6 Picas to an inch (and
12 points to a pica).
`s'
`z'
*Note Fractional Type Sizes::, for a discussion of these units.
The other measurements understood by `gtroff' depend on settings
currently in effect in `gtroff'. These are very useful for specifying
measurements which should look proper with any size of text.
`m'
Ems. This unit is equal to the current font size in points. So
called because it is _approximately_ the width of the letter `m'
in the current font.
`n'
Ens. This is half of an em.
`v'
Vertical space. This is equivalent to the current line spacing.
*Note Sizes::, for more information about this.
`M'
100ths of an em.
* Menu:
* Default Units::
File: groff, Node: Measurements-Footnotes, Up: Measurements
(1) those that specify vertical or horizontal motion or a type size
File: groff, Node: Default Units, Prev: Measurements, Up: Measurements
Default Units
-------------
Many requests take a default unit. While this can be helpful at
times, it can cause strange errors in some expressions. For example,
the line length request expects em units. Here are several attempts to
get a line length of 3.5 inches and their results:
3.5i => 3.5i
7/2 => 0i
7/2i => 0i
7i/2 => 0.1i
7i/2u => 3.5i
Everything is converted to basic units first. In the above example it
is assumed that 1i equals 240u, and 1m equals 10p (thus 1m equals 33u).
The value 7i/2 is first handled as 7i/2m, then converted to 1680u/66u
which is 25u, and this is approximately 0.1i.
Thus, the safest way to specify measurements is to always attach a
scaling indicator. If you want to multiply or divide by a certain
scalar value, use `u' as the unit for that value.
File: groff, Node: Expressions, Next: Identifiers, Prev: Measurements, Up: gtroff Reference
Expressions
===========
`gtroff' has most arithmetic operators common to other languages:
* Arithmetic: `+' (addition), `-' (subtraction), `/' (division), `*'
(multiplication), `%' (modulo).
`gtroff' only provides integer arithmetic. The internal type used
for computing results is `int', which is usually a 32bit signed
integer.
* Comparison: `<' (less than), `>' (greater than), `<=' (less than
or equal), `>=' (greater than or equal), `=' (equal), `==' (the
same as `=').
* Logical: `&' (logical and), `:' (logical or).
* Unary operators: `-' (negating, i.e. changing the sign), `+' (just
for completeness; does nothing in expressions), `!' (logical not;
this works only within `if' and `while' requests). See below for
the use of unary operators in motion requests.
* Extrema: `>?' (maximum), `<?' (minimum). For example, `5>?3'
yields `5'.
* Scaling: `(C;E)'. Evaluate E using C as the default scaling
indicator. If C is missing, ignore scaling indicators in the
evaluation of E.
Parentheses may be used as in any other language. However, in
`gtroff' they are necessary to ensure order of evaluation. `gtroff'
has no operator precedence; expressions are evaluated left to right.
This means that `gtroff' evaluates `3+5*4' as if it were parenthesized
like `(3+5)*4', not as `3+(5*4)', as might be expected.
For many requests which cause a motion on the page, the unary
operators work differently. The `+' and `-' operators then indicate a
motion relative to the current position (down or up, respectively), and
the `|' operator indicates an absolute position on the page or input
line. `+' and `-' are also treated differently by the following
requests and escapes: `bp', `in', `ll', `lt', `nm', `nr', `pl', `pn',
`po', `ps', `rt', `ti', `\R', and `\s'. Here the plus and minus signs
indicate increments and decrements.
*Note Setting Registers::.
Due to the way arguments are parsed, spaces are not allowed in
expressions, unless the entire expression is surrounded by parentheses.
*Note Request Arguments::, and *Note Conditionals and Loops::.
File: groff, Node: Identifiers, Next: Embedded Commands, Prev: Expressions, Up: gtroff Reference
Identifiers
===========
Like any other language, `gtroff' has rules for properly formed
"identifiers". In `gtroff', an identifier can be made up of almost any
printable character, with the exception of the following characters:
* Whitespace characters (spaces, tabs, and newlines).
* Backspace (ASCII `0x08' or EBCDIC `0x16') and character code
`0x01'.
* The following input characters are invalid and are ignored if
`groff' runs on a machine based on ASCII, causing a warning
message of type `input' (see *Note Debugging::, for more details):
`0x00', `0x0B', `0x0D'-`0x1F', `0x80'-`0x9F'.
And here are the invalid input characters if `groff' runs on an
EBCDIC host: `0x00', `0x08', `0x09', `0x0B', `0x0D'-`0x14',
`0x17'-`0x1F', `0x30'-`0x3F'.
Currently, some of these reserved codepoints are used internally,
thus making it non-trivial to extend `gtroff' to cover Unicode or
other character sets and encodings which use characters of these
ranges.
Note that invalid characters are removed before parsing; an
identifier `foo', followed by an invalid character, followed by
`bar' is treated as `foobar'.
For example, any of the following is valid.
br
PP
(l
end-list
@_
Note that identifiers longer than two characters with a closing bracket
(`]') in its name can't be accessed with escape sequences which expect
an identifier as a parameter. For example, `\[foo]]' accesses the
glyph `foo', followed by `]', whereas `\C'foo]'' really asks for glyph
`foo]'.
- Escape: \A'IDENT'
Test whether an identifier IDENT is valid in `gtroff'. It expands
to the character 1 or 0 according to whether its argument (usually
delimited by quotes) is or is not acceptable as the name of a
string, macro, diversion, number register, environment, or font.
It returns 0 if no argument is given. This is useful for looking
up user input in some sort of associative table.
\A'end-list'
=> 1
*Note Escapes::, for details on parameter delimiting characters.
Identifiers in `gtroff' can be any length, but, in some contexts,
`gtroff' needs to be told where identifiers end and text begins (and in
different ways depending on their length):
* Single character.
* Two characters. Must be prefixed with `(' in some situations.
* Arbitrary length (`gtroff' only). Must be bracketed with `['
and `]' in some situations. Any length identifier can be put in
brackets.
Unlike many other programming languages, undefined identifiers are
silently ignored or expanded to nothing. When `gtroff' finds an
undefined identifier, it emits a warning then:
* If the identifier is a string, macro, or diversion, `gtroff'
defines it as empty.
* If the identifier is a number register, `gtroff' defines it with a
value of 0.
*Note Warnings::.
*Note Interpolating Registers::, and *Note Strings::.
File: groff, Node: Embedded Commands, Next: Registers, Prev: Identifiers, Up: gtroff Reference
Embedded Commands
=================
Most documents need more functionality beyond filling, adjusting and
implicit line breaking. In order to gain further functionality,
`gtroff' allows commands to be embedded into the text, in two ways.
The first is a "request" which takes up an entire line, and does
some large-scale operation (e.g. break lines, start new pages).
The other is an "escape" which can be embedded anywhere in the text,
or even as an argument to a request. Escapes generally do more minor
operations like sub- and superscripts, print a symbol, etc.
* Menu:
* Requests::
* Macros::
* Escapes::
File: groff, Node: Requests, Next: Macros, Prev: Embedded Commands, Up: Embedded Commands
Requests
--------
A request line begins with a control character, which is either a
single quote (`'', the "no-break control character") or a period (`.',
the normal "control character"). These can be changed; see *Note
Character Translations::, for details. After this there may be
optional tabs or spaces followed by an identifier which is the name of
the request. This may be followed by any number of space-separated
arguments (_no_ tabs here).
Since a control character followed by whitespace only is ignored, it
is common practice to use this feature for structuring the source code
of documents or macro packages.
.de foo
. tm This is foo.
..
.
.
.de bar
. tm This is bar.
..
Another possibility is to use the blank line macro request `blm' by
assigning an empty macro to it.
.de do-nothing
..
.blm do-nothing \" activate blank line macro
.de foo
. tm This is foo.
..
.de bar
. tm This is bar.
..
.blm \" deactivate blank line macro
To begin a line with a control character without it being
interpreted, precede it with `\&'. This represents a zero width space,
which means it does not affect the output.
In most cases the period is used as a control character. Several
requests cause a break implicitly; using the single quote control
character prevents this.
* Menu:
* Request Arguments::
File: groff, Node: Request Arguments, Prev: Requests, Up: Requests
Request Arguments
.................
Arguments to requests (and macros) are processed much like the shell:
The line is split into arguments according to spaces. An argument
which is intended to contain spaces can either be enclosed in double
quotes, or have the spaces "escaped" with backslashes.
Here are a few examples:
.uh The Mouse Problem
.uh "The Mouse Problem"
.uh The\ Mouse\ Problem
The first line is the `uh' macro being called with 3 arguments, `The',
`Mouse', and `Problem'. The latter two have the same effect of calling
the `uh' macro with one argument, `The Mouse Problem'.(1) (*note
Request Arguments-Footnote-1::)
A double quote which isn't preceded by a space doesn't start a macro
argument. If not closing a string, it is printed literally.
For example,
.xxx a" "b c" "de"fg"
has the arguments `a"', `b c', `de', and `fg"'.
Duoble quotes in the `ds' request are handled differently. *Note
Strings::, for more details.
File: groff, Node: Request Arguments-Footnotes, Up: Request Arguments
(1) The last solution, i.e., using escaped spaces, is "classical" in
the sense that it can be found in most `troff' documents.
Nevertheless, it is not optimal in all situations, since `\ ' inserts a
fixed-width, non-breaking space character which can't stretch.
`gtroff' provides a different command `\~' to insert a stretchable,
non-breaking space.
File: groff, Node: Macros, Next: Escapes, Prev: Requests, Up: Embedded Commands
Macros
------
`gtroff' has a "macro" facility for defining a series of lines which
can be invoked by name. They are called in the same manner as requests
- arguments also may be passed in the same manner.
*Note Writing Macros::, and *Note Request Arguments::.
File: groff, Node: Escapes, Prev: Macros, Up: Embedded Commands
Escapes
-------
Escapes may occur anywhere in the input to `gtroff'. They usually
begin with a backslash and are followed by a single character which
indicates the function to be performed. The escape character can be
changed; see *Note Character Translations::.
Escape sequences which require an identifier as a parameter accept
three possible syntax forms.
* The next single character is the identifier.
* If this single character is an opening parenthesis, take the
following two characters as the identifier. Note that there is no
closing parenthesis after the identifier.
* If this single character is an opening bracket, take all characters
until a closing bracket as the identifier.
Examples:
\fB
\n(XX
\*[TeX]
Other escapes may require several arguments and/or some special
format. In such cases the argument is traditionally enclosed in single
quotes (and quotes are always used in this manual for the definitions
of escape sequences). The enclosed text is then processed according to
what that escape expects. Example:
\l'1.5i\(bu'
Note that the quote character can be replaced with any other
character which does not occur in the argument (even a newline or a
space character) in the following escapes: `\o', `\b', and `\X'. This
makes e.g.
A caf
\o
e\'
in Paris
=> A cafe' in Paris
possible, but it is better not to use this feature to avoid confusion.
The following escapes sequences (which are handled similarly to
characters since they don't take a parameter) are also allowed as
delimiters: `\%', `\ ', `\|', `\^', `\{', `\}', `\'', `\`', `\-', `\_',
`\!', `\?', `\@', `\)', `\/', `\,', `\&', `\~', `\0', `\a', `\c', `\d',
`\e', `\E', `\p', `\r', `\t', and `\u'. Again, don't use these if
possible.
No newline characters as delimiters are allowed in the following
escapes: `\A', `\Z', `\C', and `\w'.
Finally, the escapes `\D', `\h', `\H', `\l', `\L', `\N', `\R', `\s',
`\S', `\v', and `\x' can't use the following characters as delimiters:
* The digits `0'-`9'.
* The (single-character) operators `+-/*%<>=&:().'.
* The space, tab, and newline characters.
* All escape sequences except `\%', `\{', `\}', `\'', `\`', `\-',
`\_', `\!', `\@', `\/', `\c', `\e', and `\p'.
To have a backslash (actually, the current escape character) appear
in the output several escapes are defined: `\\', `\e' or `\E'. These
are very similar, and only differ with respect to being used in macros
or diversions. *Note Copy-in Mode::, and *Note Diversions::, for more
information.
*Note Identifiers::, and *Note Character Translations::.
* Menu:
* Comments::
File: groff, Node: Comments, Prev: Escapes, Up: Escapes
Comments
........
Probably one of the most(1) (*note Comments-Footnote-1::) common
forms of escapes is the comment.
- Escape: \"
Start a comment. Everything to the end of the input line is
ignored.
This may sound simple, but it can be tricky to keep the comments
from interfering with the appearance of the final output.
If the escape is to the right of some text or a request, that
portion of the line is ignored, but the space leading up to it is
noticed by `gtroff'. This only affects the `.ds' and `.as'
request.
One possibly irritating idiosyncracy is that tabs must not be used
to line up comments. Tabs are not treated as white space between
the request and macro arguments.
A comment on a line by itself is treated as a blank line, because
after eliminating the comment, that is all that remains:
Test
\" comment
Test
produces
Test
Test
To avoid this, it is common to start the line with `.\"' which
causes the line to be treated as an undefined request and thus
ignored completely.
Another commenting scheme seen sometimes is three consecutive
single quotes (`'''') at the beginning of a line. This works, but
`gtroff' gives a warning about an undefined macro (namely `'''),
which is harmless, but irritating.
- Escape: \#
To avoid all this, `gtroff' has a new comment mechanism using the
`\#' escape. This escape works the same as `\"' except that the
newline is also ignored:
Test
\# comment
Test
produces
Test Test
as expected.
- Request: .ig yy
Ignore all input until `gtroff' encounters the macro named `.'YY
on a line by itself (or `..' if YY is not specified). This is
useful for commenting out large blocks of text:
text text text...
.ig
This is part of a large block
of text that has been
temporarily(?) commented out.
We can restore it simply by removing
the .ig request and the ".." at the
end of the block.
..
More text text text...
produces
text text text... More text text text...
Note that the commented-out block of text does not cause a break.
The input is read in copy-mode; auto-incremented registers _are_
affected (*note Auto-increment::).
File: groff, Node: Comments-Footnotes, Up: Comments
(1) Unfortunately, this is a lie. But hopefully future `gtroff'
hackers will believe it `:-)'
File: groff, Node: Registers, Next: Manipulating Filling and Adjusting, Prev: Embedded Commands, Up: gtroff Reference
Registers
=========
Numeric variables in `gtroff' are called "registers". There are a
number of built-in registers, supplying anything from the date to
details of formatting parameters.
*Note Identifiers::, for details on register identifiers.
* Menu:
* Setting Registers::
* Interpolating Registers::
* Auto-increment::
* Assigning Formats::
* Built-in Registers::